home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
nan_news
/
toolkit
/
outp.asm
< prev
next >
Wrap
Assembly Source File
|
1991-08-15
|
4KB
|
114 lines
; File......: OUTP.ASM
; Author....: Ted Means
; Date......: $Date: 15 Aug 1991 23:07:08 $
; Revision..: $Revision: 1.2 $
; Log file..: $Logfile: E:/nanfor/src/outp.asv $
;
; This function is an original work by Ted Means and is placed in the
; public domain.
;
; Modification history:
; ---------------------
;
; $Log: E:/nanfor/src/outp.asv $
;
; Rev 1.2 15 Aug 1991 23:07:08 GLENN
; Forest Belt proofread/edited/cleaned up doc
;
; Rev 1.1 14 Jun 1991 19:54:52 GLENN
; Minor edit to file header
;
; Rev 1.0 01 Apr 1991 01:03:46 GLENN
; Nanforum Toolkit
;
; $DOC$
; $FUNCNAME$
; FT_OUTP()
; $CATEGORY$
; DOS/BIOS
; $ONELINER$
; Write a byte to a specified I/O port
; $SYNTAX$
; FT_OUTP( <nPort>, <nValue> ) -> lResult
; $ARGUMENTS$
; <nPort> is the port from which to retrieve the byte.
;
; <nValue> is the value between 0 and 255 to write to the port.
; $RETURNS$
; .T. if all parameters were valid and the byte was written to
; the port.
; .F. if invalid parameters were passed.
; $DESCRIPTION$
; It may sometimes be useful to write a byte to a port without having
; to resort to C or assembler. This function allows you to do so.
;
; The source code is written to adhere to Turbo Assembler's IDEAL mode.
; To use another assembler, you will need to rearrange the PROC and
; SEGMENT directives, and also the ENDP and ENDS directives (a very
; minor task).
; $EXAMPLES$
; lOk := FT_OUTP( 100, 0 ) // send a Chr(0) to port 100 (064h)
; $SEEALSO$
; FT_INP()
; $END$
;
IDEAL
Public FT_OUTP
Extrn __ParInfo:Far
Extrn __ParNI:Far
Extrn __RetL:Far
Segment _NanFor Word "CODE"
Assume CS:_NanFor
Proc FT_OUTP Far
Xor AX,AX ; Request param count
Push AX ; Put request on stack
Call __ParInfo ; Get param count
Add SP,2 ; Realign stack
Cmp AX,2 ; At least two params?
JNB GetTypes ; If so, continue
BadParam:Xor AX,AX ; Set return value to false
Jmp Short Exit ; Quit
GetTypes:Mov CX,2 ; Specify param count
Top: Push CX ; Put param # on stack
Call __ParInfo ; Get param type
Pop CX ; Realign stack and restore CX
Test AX,2 ; Numeric?
JZ BadParam ; No, so abort
Loop Top ; Go to top of loop
Mov AX,1 ; Specify first param
Push AX ; Put param # on stack
Call __ParNI ; Get value
Add SP,2 ; Realign stack
Cmp AX,255 ; Value valid?
JA BadParam ; No, so abort
Push AX ; Save value for later
Mov AX,2 ; Specify first param
Push AX ; Put param # on stack
Call __ParNI ; Get value
Add SP,2 ; Realign stack
Mov DX,AX ; Move port # to DX
Pop AX ; Get value from stack
Out DX,AL ; Write a byte to the port
Mov AX,1 ; Set return value to true
Exit: Push AX ; Put return value on stack
Call __RetL ; Return it to Clipper app
Add SP,2 ; Realign stack
Ret
Endp FT_OUTP
Ends _NanFor
End